/**
* Class Name: IfulfillMyTeamSearchCntrl 
* Author: Accenture
* Date: 13-Sep -2011
* Requirement/Project Name: iFulfill
* Requirement/Project Description: Manager should be able to see his team items on My Team Item report.
**/

public class IfulfillMyTeamSearchCntrl 
{
    public String  selectedRegion {get;set;}  
    public String  selectedTransactionType {get;set;}  
    public List<selectOption> stepOption {get;set;}
    public String  currentFunctionName {get;set;}  
    public String  productFamilyName{get;set;}  
    public String currentTaskName {get;set;}  
    public String status {get;set;}  
    public Boolean escalatedCheckBox{get;set;}   
  
   /* * Constructor * **/
    public IfulfillMyTeamSearchCntrl() 
    {
        stepOption = new  List<selectOption>();
        stepOption.add(new selectOption('',IfullfillTextConstant.PICKLIST_NONE_TXT)); 
        escalatedCheckBox = false;
    }
   /*
    * Return the Task associated with the selected Function.
    *
    **/
    public void currentTask()
    {
        List<selectOption> options = new List<selectOption>(); 
        options.add(new selectOption('', IfullfillTextConstant.PICKLIST_NONE_TXT)); 
        
        // get the task related with the function        
        for (Step_Definition__c stepDef : [ select name ,id from  Step_Definition__c where  Stage__r.name = :currentFunctionName  order by name asc])
        {
                options.add(new selectOption(stepDef.Name, stepDef.Name));
        }
        stepOption = options;
    }
    /*
    * Returns the Function  of workflow associated with the FI.
    *
    **/ 
    public List<selectOption> getCurrentFunction()
    {
        List<selectOption> options = new List<selectOption>(); 
        options.add(new selectOption('', IfullfillTextConstant.PICKLIST_NONE_TXT)); 
        for (Stage_Definition__c stagDef : [SELECT Id, Name FROM  Stage_Definition__c  order by name asc]) 
        { 
            options.add(new selectOption(stagDef.Name, stagDef.Name)); 
        }
        return options; 
    }
    
    /*
    * Returns the FI  product family.
    *
    **/
    public List<SelectOption> getProductFamily()
    {
        List<selectOption> options = new List<selectOption>(); 
        options.add(new selectOption('',IfullfillTextConstant.PICKLIST_NONE_TXT)); 
        Schema.DescribeFieldResult rest =   Fullfilment_Item__c.Product_Family__c.getDescribe();
        for(Schema.PickListEntry FinalsPickVal : rest.getPicklistValues())
        {
            options.add(new SelectOption(FinalsPickVal.getValue(),FinalsPickVal.getLabel()));
        }
        return options;
    }  
    /*
    * Returns the WorkFlow Status  of the FI 
    *
    **/
    public List<SelectOption> getWorkflowStatus()
    {
        List<selectOption> options = new List<selectOption>(); 
        options.add(new selectOption('', IfullfillTextConstant.PICKLIST_NONE_TXT)); 
        Schema.DescribeFieldResult rest =   Fullfilment_Item__c.Status__c.getDescribe();
        for(Schema.PickListEntry FinalsPickVal : rest.getPicklistValues())
        {
            options.add(new SelectOption(FinalsPickVal.getValue(),FinalsPickVal.getLabel()));
        }
        return options;
    }  
    /*
    * Converts the escalted value to the numeric
    *
    **/
    public String getEscalated()
    {
        if(escalatedCheckBox)
        {
            return '1';
        }
        else
        {
          return '0';
        }
        
    }
    
    /*
    * Action associated with clear button.
    *
    **/
    
    public void clear()
    {
        List<selectOption> options = new List<selectOption>(); 
        options.add(new selectOption('',IfullfillTextConstant.PICKLIST_NONE_TXT)); 
        stepOption = options;
        escalatedCheckBox = false;
    }
   /*
    * Returns the FI Region
    *
    **/
    public List<SelectOption> getRegion()
    {
        List<selectOption> options = new List<selectOption>(); 
        options.add(new selectOption('', IfullfillTextConstant.PICKLIST_NONE_TXT)); 
        Schema.DescribeFieldResult rest =   Fullfilment_Item__c.Region__c.getDescribe();
        for(Schema.PickListEntry FinalsPickVal : rest.getPicklistValues())
        {
            options.add(new SelectOption(FinalsPickVal.getValue(),FinalsPickVal.getLabel()));
        }
        return options;
    }  
     /*
    * Returns the FI  transaction type.
    *
    **/
    public List<SelectOption> getTransactionType()
    {
        List<selectOption> options = new List<selectOption>(); 
        options.add(new selectOption('', IfullfillTextConstant.PICKLIST_NONE_TXT)); 
        Schema.DescribeFieldResult rest =   Fullfilment_Item__c.Transaction_Type__c.getDescribe();
        for(Schema.PickListEntry FinalsPickVal : rest.getPicklistValues())
        {
            options.add(new SelectOption(FinalsPickVal.getValue(),FinalsPickVal.getLabel()));
        }
        return options;
    }  
    
  
}